/**
 * 滤镜和自定义shader方法写在这里
 */
class ShaderUtil {
    public static ImgGray(img:eui.Image)
    {
        if(!img)return;
        //关闭颜色渲染通道，灰化图片
        let closeMatrix = [
            0.3,0.6,0,0,0,
            0.3,0.6,0,0,0,
            0.3,0.6,0,0,0,
            0,0,0,1,0 
        ];
        let flilter = new egret.ColorMatrixFilter(closeMatrix);
        img.filters = [flilter];
    }

    public static ImgDark(img:eui.Image, value:number)
    {
        //使图片变暗
        if(!img)return;
        let closeMatrix = [
            1,0,0,0,value,
            0,1,0,0,value,
            0,0,1,0,value,
            0,0,0,1,0
        ];
        let flilter = new egret.ColorMatrixFilter(closeMatrix);
        img.filters = [flilter];
    }

    public static ImgDefault(img:eui.Image)
    {
        //使图片回复
        if(!img)return;
        img.filters = null;
    }
}